import React from 'react';
import { Button, Tooltip, useDisclosure } from '@nextui-org/react';
import { FiShare } from 'react-icons/fi';
import CreateShareModal from '../share/CreateShareModal';

interface ShareNoteButtonProps {
    noteId: number;
    onShareCreated?: () => void;
}

export default function ShareNoteButton({ noteId, onShareCreated }: ShareNoteButtonProps) {
    const { isOpen, onOpen, onClose } = useDisclosure();

    return (
        <>
            <Tooltip content="分享笔记">
                <Button
                    isIconOnly
                    variant="light"
                    onPress={onOpen}
                    aria-label="分享笔记"
                >
                    <FiShare size={20} />
                </Button>
            </Tooltip>

            <CreateShareModal
                noteId={noteId}
                isOpen={isOpen}
                onClose={onClose}
                onSuccess={onShareCreated}
            />
        </>
    );
} 